import { BrowserRouter, useRoutes } from 'react-router-dom';
import './App.css';
import { useAppDispatch, useAppSelector } from './store/hook';
import { setName } from './store/slices/user';
import { routes } from './router';

function AppRoutes() {
  return useRoutes(routes);
}

function App() {
  const user = useAppSelector((state) => state.user.name);
  const dispatch = useAppDispatch();
  const handleEditName = () => {
    dispatch(setName('66'));
  };

  return (
    <BrowserRouter>
      <p>{user}</p>
      <button onClick={handleEditName}>修改为66</button>
      <AppRoutes />
    </BrowserRouter>
  );
}

export default App;
